import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick3D

import Utils

import "../EventBus"
import "../framework"
import "../Levels"

Item
{
    Item {
        id: __materialLibrary__
    }

    StackLayout{
        id:stack
        anchors.fill: parent
        currentIndex: {
            if(!EventBus.currentLevel)
            {
                return 0
            }

            return 1
        }

        Item{
            Column{
                anchors.centerIn: parent
                spacing: 10
                Button{
                    text:"创建房间"
                    onClicked: {
                        let level = EventBus.levelList.caveLevel.createObject()
                        level.startAsListenServer(2425)
                        EventBus.currentLevel = level
                    }
                }

                Button{
                    text:"加入房间"
                    onClicked: {
//                        let level = EventBus.levelList.homeLevel.createObject()
//                        level.startAsClient("qtro://localhost:2425")
//                        EventBus.currentLevel = level
                    }
                }

            }
        }



        Item
        {
            id:gameViewRect
            Binding{
                target:{
                    if(EventBus.currentLevel)
                    {
                        return EventBus.currentLevel.item
                    }
                    return null
                }
                property:"parent"
                value:gameViewRect
            }
        }

    }




}
